package com.cjl.learn.builder.way1.clone;

import com.cjl.learn.builder.way1.entity.Sheep;
import com.cjl.learn.builder.way1.entity.Toy;

/**
 * 浅拷贝
 * Created by Enzo Cotter on 2019-08-23.
 */
public class CloneWay1 {

    public static void main(String[] args) {
        Sheep sheep = new Sheep();
        Toy toy = new Toy();
        toy.setName("ball");
        sheep.setName("duoli");
        sheep.setToy(toy);

        Sheep clone = sheep.clone();
        System.out.println(sheep == clone); // false
        System.out.println(sheep.getToy() == clone.getToy()); // true
    }
}
